package com.yyfax.ph.home.recommendloan.otherinfo;

import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.ph.base.YJPH;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * M: 其他资料
 * Created by ying_he on 2017/11/9.<br>
 * Copyright  2017 www.yylending.com. All Rights Reserved.<br><br>
 */

public class OtherInfoModel extends Model<BaseResultEntity>{

	@Override
	public Observable getObservable(Object params, int functionalCode) {
		Service service = (Service) NetworkHelper.createService(Service.class);
		String token = YJPH.getInstance().getPreferenceManager().getLoginToken();
		return service.uploadOtherInfo(token, (OtherInfoParams) params);
	}

	@Override
	public void onNext(BaseResultEntity entity) {
		UploadOtherInfoResult result = cast(entity);
		EventAgent.post(result);
	}

	private interface Service {
		@POST("apply/record/more")
		Observable<UploadOtherInfoResult> uploadOtherInfo(@Header("token") String token, @Body OtherInfoParams otherInfoParams);
	}

	class UploadOtherInfoResult extends BaseResultEntity{}

	static class OtherInfoParams{
		/**
		 * 推荐编号
		 */
		public String rcmdId = "";
		/**
		 *雇佣类型 010:企业主 020:上班族
		 */
		public String employeeType = "";
		/**
		 *单位名称
		 */
		public String corpName = "";
		/**
		 *是否有本地房产 0:无 1:有（长度1位）
		 */
		public String localHouseFlag = "";
		/**
		 *居住状况
		 */
		public String livingCondition = "";
		/**
		 *婚姻状况
		 */
		public String marriage = "";
		/**
		 *教育程度
		 */
		public String educationLevel = "";
	}
}
